class Solution {
    const string data[10] = {"", "", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"};
    vector<string> ret;
    string path;

    void dfs(string& digits, int pos)
    {
        if (path.size() == digits.size())
        {
            ret.push_back(path);
            return;
        }

        for (int i = pos; i < digits.size(); i++)
        {
            for (int j = 0; j < data[digits[i] - '0'].size(); j++)
            {
                path.push_back(data[digits[i] - '0'][j]);
                dfs(digits, i + 1);
                path.pop_back();
            }
        }
    }
public:
    vector<string> letterCombinations(string digits) {
        if (digits.size() == 0)
            return ret;
        dfs(digits, 0);
        return ret;
    }
};